//
//  HELogisticsCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/13.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HELogisticsCell.h"

@interface HELogisticsCell ()

@property (nonatomic, strong) UILabel *timeLb;
@property (nonatomic, strong) UILabel *contentLb;

@property (nonatomic, strong) UIView *dotView;
@property (nonatomic, strong) UIImageView *finishView;

@end

@implementation HELogisticsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = KWhiteColor;
        
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    _timeLb = [[UILabel alloc] init];
    _timeLb.font = DYFont(14);
    _timeLb.text = @"0000-00-00\n00:00:00";
    _timeLb.textColor = CNavLightBlackColor;
    _timeLb.numberOfLines = 2;
    _timeLb.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_timeLb];
    
    _contentLb = [[UILabel alloc] init];
    _contentLb.font = DYFont(14);
    _contentLb.text = @"-";
    _contentLb.textColor = CNavLightBlackColor;
    _contentLb.numberOfLines = 0;
    [self.contentView addSubview:_contentLb];
    
    [_timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(20);
        make.left.equalTo(self.contentView).mas_offset(10);
        make.width.mas_offset([_timeLb.text widthForFont: DYFont(14)] + 10);
    }];
    
    
    UIView *spiteWarp = [UIView new];
    [self.contentView addSubview:spiteWarp];
    
    [spiteWarp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.width.mas_offset(20);
        make.left.equalTo(_timeLb.mas_right).mas_offset(5);
        make.bottom.equalTo(self.contentView);
    }];
    

    UIView *line = [UIView new];
    line.backgroundColor = CSplitLineColor;
    [spiteWarp addSubview:line];
    
    _dotView = [UIView new];
    _dotView.backgroundColor = CSplitLineColor;
    [spiteWarp addSubview:_dotView];
    [_dotView hg_setAllCornerWithCornerRadius: 5];
    
    _finishView = [UIImageView new];
    _finishView.image = IMAGE_NAMED(@"check_s");
    _finishView.hidden = YES;
    [spiteWarp addSubview:_finishView];

    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(spiteWarp);
        make.centerX.equalTo(spiteWarp);
        make.width.mas_offset(2);
        make.bottom.equalTo(spiteWarp);
    }];
    
    [_dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(spiteWarp).mas_offset(20);
        make.centerX.equalTo(spiteWarp);
        make.width.height.mas_offset(10);
    }];
    
    [_finishView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(spiteWarp).mas_offset(20);
        make.centerX.equalTo(spiteWarp);
        make.width.height.mas_offset(22);
    }];
    
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(20);
        make.left.equalTo(spiteWarp.mas_right).mas_offset(5);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-15);
        make.height.mas_greaterThanOrEqualTo(26);
        make.bottom.equalTo(self.contentView.mas_bottom).mas_offset(-5);
    }];
     
}

- (void)setModel:(HETraces *)model {
    _model = model;
    
    _timeLb.text = model.KAcceptTime;
    _contentLb.text = model.AcceptStation;
}

- (void)finishStateView {
    _timeLb.textColor = CNavBgColor;
    _contentLb.textColor = CNavBgColor;
    _finishView.hidden = NO;
}

- (void)normalViwe {
    _timeLb.textColor = CNavLightBlackColor;
    _contentLb.textColor = CNavLightBlackColor;
    _finishView.hidden = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
